How can I convert a Python if-statement loop to a one-liner

visit shbcf.ru